<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      // 页面DOM元素加载完成后执行回调
      document.addEventListener("DOMContentLoaded", function () {
        const h1El = document.querySelector("h1");
        console.log(h1El);
        console.log("DOM load");
      });

      // 页面中所有资源都加载完成后执行
      window.addEventListener("load", function () {
        console.log("window load");
      });
    </script>
  </head>
  <body>
    <h1>hello world</h1>
    <img
      src="https://cn.bing.com/images/search?q=%E5%9B%BE%E7%89%87&FORM=IQFRBA&id=47835E12BAC60725340FFDC4318EDEF05EB8297E"
      alt=""
    />
  </body>
</html>
